package domain;

public class User {
	private String name;
	private int userId;
	private Preference preference;

	public User(String name, int userId) {
		this.name = name;
		this.userId = userId;
		this.preference = new Preference();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) throws Exception {

		if (name == null) {
			throw (new Exception("Name is incorrect!"));
		} else {
			this.name = name;
		}
	}

	public Preference getPreference() {
		return preference;
	}

	public void setPreference(Preference preference) {
		this.preference = preference;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) throws Exception {

		if (userId < 0) {
			throw (new Exception("UserId is incorrent!"));
		} else {
			this.userId = userId;
		}
	}

	public void rateMovie(Movie movie, int rate) {

		Rating rating = new Rating(movie.getMovieDescription().getMovieId(),
				rate);
		preference.getRatingList().add(rating);

	}

	@Override
	public String toString() {
		return "User [name=" + name + ", userId=" + userId + "]";
	}


}
